fontawesome package | 您所在的位置:网站首页 › r markdown how to insert page › fontawesome package |
The fontawesome R package makes it very easy to insert Font Awesome icons into R Markdown documents and Shiny apps (or, anywhere else you need to put them). ExamplesThe fa() function can be used to insert an FA icon. For example, we can get the r-project icon in steelblue: fa(name = "r-project", fill = "steelblue") #>As can be seen, what we really get from the function is an SVG object that represents the icon. This can be directly used within R Markdown with: {text} `r fa(...)` {text}Font Awesome SVG icons are great to use instead of tags + font files for a few reasons: There is less overhead in a Shiny app or R Markdown document since an tag requires computation to obtain the icon ( tags represent the actual icon)Using tags has a 'being online' requirement since network activity is necessary for resolving these tags (SVGs in fontawesome are stored in the package, so, no Internet connectivity is necessary for that)There are styling options available for SVG that aren't there for icon fontsR MarkdownHere is an example R Markdown document that includes Font Awesome icons: --- title: "Font Awesome in R Markdown" output: html_document --- ```{r load_packages, message=FALSE, warning=FALSE, include=FALSE} library(fontawesome) ``` # Just a few tests with `r fa("font-awesome-logo-full", fill = "forestgreen")` It works well in headings... # `r fa("r-project", fill = "steelblue")` H1 Heading ## `r fa("r-project", fill = "steelblue")` H2 Heading ### `r fa("r-project", fill = "steelblue")` H3 Heading #### `r fa("r-project", fill = "steelblue")` H4 Heading ##### `r fa("r-project", fill = "steelblue")` H5 Heading ...and works equally well within inline text: `r fa("r-project", fill = "steelblue")`.This will appear, when knit, as: ShinyHere鈥檚 a Shiny app (from the Shiny Gallery) that鈥檚 been slightly modified to incorporate Font Awesome icons in the text above the three search fields: library(shiny) library(DT) library(ggplot2) library(fontawesome) ui |
CopyRight 2018-2019 实验室设备网 版权所有 |